package com.bocloud.cmp.entity.resource;

import java.util.Date;
import java.util.List;

import org.springframework.format.annotation.DateTimeFormat;

import com.bocloud.common.utils.DateSerializer;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.bean.GenericEntity;
import com.bocloud.entity.meta.PKStrategy;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * 网络实体类
 * 
 * @author dongkai
 *
 */
@Table("network")
public class Network extends GenericEntity {

	@PK(value = PKStrategy.AUTO)
	private Long id; // ID
	@Column("network_id")
	private String networkId; // 网络ID
	@Column("vendor_id")
	private Long vendorId; // 云供应商ID
	@IgnoreAll
	private String vendorName; // 云供应商名称
	@Column("region")
	private Long region; // 镜像所在区域
	@IgnoreAll
	private String regionName; // 镜像所在区域名称
	@Column("type")
	private String type;// 网络类型
	@Column("shared")
	private Boolean shared;// 是否共享
	@Column("admin_stateup")
	private Boolean adminStateup;
	@IgnoreAll
	private List<Subnet> subnets;
	@Column("expired_time")
	@JsonSerialize(using = DateSerializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date expiredTime;// 过期时间
	@Column("network_val")
	private String networkVal;// 网络value
	@Column("vdc_id")
	private Long vdcId; // 数据中心ID
	@IgnoreAll
	private String vdcName; // 数据中心名称
	@Column("port_num")
	private Integer portNum;// 端口数量
	@Column("is_router_external")
	private Boolean isRouterExternal;// 是否外部访问
	@Column("segmentation_id")
	private String segmentationId;// 段Id
	@Column("phy_network")
	private String phyNetwork;// 物理网络
	@IgnoreAll
	private List<PortGroup> groups;

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the networkId
	 */
	public String getNetworkId() {
		return networkId;
	}

	/**
	 * @param networkId
	 *            the networkId to set
	 */
	public void setNetworkId(String networkId) {
		this.networkId = networkId;
	}

	/**
	 * @return the vendorId
	 */
	public Long getVendorId() {
		return vendorId;
	}

	/**
	 * @param vendorId
	 *            the vendorId to set
	 */
	public void setVendorId(Long vendorId) {
		this.vendorId = vendorId;
	}

	/**
	 * @return the vendorName
	 */
	public String getVendorName() {
		return vendorName;
	}

	/**
	 * @param vendorName
	 *            the vendorName to set
	 */
	public void setVendorName(String vendorName) {
		this.vendorName = vendorName;
	}

	/**
	 * @return the region
	 */
	public Long getRegion() {
		return region;
	}

	/**
	 * @param region
	 *            the region to set
	 */
	public void setRegion(Long region) {
		this.region = region;
	}

	/**
	 * @return the regionName
	 */
	public String getRegionName() {
		return regionName;
	}

	/**
	 * @param regionName
	 *            the regionName to set
	 */
	public void setRegionName(String regionName) {
		this.regionName = regionName;
	}

	/**
	 * @return the type
	 */
	public String getType() {
		return type;
	}

	/**
	 * @param type
	 *            the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * @return the shared
	 */
	public Boolean getShared() {
		return shared;
	}

	/**
	 * @param shared
	 *            the shared to set
	 */
	public void setShared(Boolean shared) {
		this.shared = shared;
	}

	/**
	 * @return the adminStateup
	 */
	public Boolean getAdminStateup() {
		return adminStateup;
	}

	/**
	 * @param adminStateup
	 *            the adminStateup to set
	 */
	public void setAdminStateup(Boolean adminStateup) {
		this.adminStateup = adminStateup;
	}

	/**
	 * @return the subnets
	 */
	public List<Subnet> getSubnets() {
		return subnets;
	}

	/**
	 * @param subnets
	 *            the subnets to set
	 */
	public void setSubnets(List<Subnet> subnets) {
		this.subnets = subnets;
	}

	/**
	 * @return the expiredTime
	 */
	public Date getExpiredTime() {
		return expiredTime;
	}

	/**
	 * @param expiredTime
	 *            the expiredTime to set
	 */
	public void setExpiredTime(Date expiredTime) {
		this.expiredTime = expiredTime;
	}

	/**
	 * @return the networkVal
	 */
	public String getNetworkVal() {
		return networkVal;
	}

	/**
	 * @param networkVal
	 *            the networkVal to set
	 */
	public void setNetworkVal(String networkVal) {
		this.networkVal = networkVal;
	}

	/**
	 * @return the vdcId
	 */
	public Long getVdcId() {
		return vdcId;
	}

	/**
	 * @param vdcId
	 *            the vdcId to set
	 */
	public void setVdcId(Long vdcId) {
		this.vdcId = vdcId;
	}

	/**
	 * @return the vdcName
	 */
	public String getVdcName() {
		return vdcName;
	}

	/**
	 * @param vdcName
	 *            the vdcName to set
	 */
	public void setVdcName(String vdcName) {
		this.vdcName = vdcName;
	}

	/**
	 * @return the portNum
	 */
	public Integer getPortNum() {
		return portNum;
	}

	/**
	 * @param portNum
	 *            the portNum to set
	 */
	public void setPortNum(Integer portNum) {
		this.portNum = portNum;
	}

	public Boolean getIsRouterExternal() {
		return isRouterExternal;
	}

	public void setIsRouterExternal(Boolean isRouterExternal) {
		this.isRouterExternal = isRouterExternal;
	}

	public String getSegmentationId() {
		return segmentationId;
	}

	public void setSegmentationId(String segmentationId) {
		this.segmentationId = segmentationId;
	}

	public String getPhyNetwork() {
		return phyNetwork;
	}

	public void setPhyNetwork(String phyNetwork) {
		this.phyNetwork = phyNetwork;
	}

	/**
	 * @return the groups
	 */
	public List<PortGroup> getGroups() {
		return groups;
	}

	/**
	 * @param groups
	 *            the groups to set
	 */
	public void setGroups(List<PortGroup> groups) {
		this.groups = groups;
	}

	public void preSave(Long createrId, Long menderId, Long vendorId, Long vdcId) {
		this.setCreaterId(createrId);
		this.setMenderId(menderId);
		this.setVendorId(vendorId);
		this.setVdcId(vdcId);
	}

}